from random import randint

from pydelaunay import DG, SG, vsearch, dPoint


X, Y = 15, 15
Q = [(0, 0), (X, 0), (X, Y), (0, Y)]


def randpoints(Q, n=9):
    X, Y = [q[0] for q in Q], [q[1] for q in Q]
    xmin, xmax, ymin, ymax = min(X)+1, max(X)-1, min(Y)+1, max(Y)-1
    P = [] # input points
    while len(P) < n:
        p = randint(xmin, xmax), randint(ymin, ymax)
        if not p in P: P.append(p)
    while p in P: p = randint(xmin, xmax), randint(ymin, ymax)
    p = dPoint(True, *p) # input: vsearch point
    return P, p

def main():
    i = 0
    while i < 1000:
        print i
        i += 1
        P, p = randpoints(Q)
        j = 0
        while j < 500:
            #print i#, '#######################################'
            j += 1
            DG(P, Q)


if __name__ == '__main__': main()
# vsearch(p, D, S)
